local items = {
	settingsfile = "335火法.json",
    callback = GUICallback,
	{ type = "title", text = "335火法 |c0000CED1糊涂虫" },
	{ type = "separator" },
	{ type = "title", text = "|cffFFFF00基础模块" },
    { type = "entry", text = "\124T"..GetItemIcon(33312)..":26:26\124t T9装备ID", tooltip = "战斗前替换设置的2件T9装备ID，施放火盾，提高暴击", enabled = true, value = "47753,47755", width = 100, key = "EquipId" },
    { type = "entry", text = "\124T"..GetItemIcon(33312)..":26:26\124t 使用法力宝石 < MP%", tooltip = "使用法力宝石 < MP%", enabled = true, value = 70, key = "ManaGem" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(12051))..":26:26\124t 唤醒 < MP%", tooltip = "唤醒 < MP%", enabled = true, value = 10, key = "Evocation" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(54999))..":26:26\124t 调试模式", tooltip = "开启后打印施法信息", enabled = false, key = "Debug" },

    { type = "separator" },
	{ type = "title", text = "|cffFFFF00辅助功能" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(1953))..":26:26\124t 释放闪现", tooltip = "按住左Shift施放闪现", enabled = true, key = "Blink" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(45438))..":26:26\124t 释放冰箱 < HP%", tooltip = "按住右Shift主动施放冰箱，关闭后无法自动开启", enabled = true, value = 10, key = "IceBlock" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(54999))..":26:26\124t 工程手套 < 码", tooltip = "工程手套CD好了就用", enabled = true, value = 41, key = "UseHand" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(55016))..":26:26\124t 工程鞋子（右Ctrl）", tooltip = "按住右Ctrl施放工程疾跑", enabled = true, key = "UseFoot" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(475))..":26:26\124t 自动解诅咒", tooltip = "开启自动解诅咒功能", enabled = false, key = "RemoveCurse" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(30449))..":26:26\124t 自动偷魔法", tooltip = "开启后进行自动偷取魔法", enabled = false, key = "Spellsteal" },
	
    { type = "separator" },
	{ type = "title", text = "|cffFFFF00保命" },
    { type = "entry", text = "\124T"..GetItemIcon(36894)..":26:26\124t  治疗石 < HP% ", tooltip = "治疗石 < HP%", enabled = true, value = 20, key = "FelHealthstone" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(1463))..":26:26\124t 释放法力护盾 < HP%", tooltip = "开启法力护盾 < HP%", enabled = true, value = 30, key = "ManaShield" },

    { type = "separator" },
	{ type = "title", text = "|cffFFFF00 左爆发（按住左Ctrl）" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(12042))..":26:26\124t 开启自动爆发", tooltip = "英勇、嗜血、能量灌注的时候自动开启爆发", enabled = true, key = "AutoBurst" },
    { type = "separator" },
	{ type = "title", text = "|cffFFFF00炎爆术" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(42891))..":26:26\124t 释放炎爆术", tooltip = "这里设置炎爆术是为了提高技能优先级", enabled = true, key = "Pyroblast" },

    { type = "separator" },
	{ type = "title", text = "|cffFFFF00 群体AOE输出（左暴风Alt右烈焰）" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(10))..":26:26\124t 自动释放暴风雪 > 怪物数", tooltip = "自动释放暴风雪 > 怪物数", enabled = true, value = 3, key = "BlizzardCount" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(42926))..":26:26\124t 自动释放烈焰风暴 > 怪物数", tooltip = "自动释放烈焰风暴 > 怪物数", enabled = true, value = 3, key = "FlamestrikeCount" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(55360))..":26:26\124t 自动活动炸弹 < 施法距离", tooltip = "施法范围内目标全部释放活动炸弹", enabled = true, value = 41, min = 36, max = 41, step = 1, key = "LivingBomb" },

    { type = "separator" },
	{ type = "title", text = "|cffFFFF00折磨火输出" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(2948))..":26:26\124t 灼烧", tooltip = "补充5%暴击使用", enabled = false, key = "Scorch" },
    { type = "entry", text = "\124T"..select(3, GetSpellInfo(11129))..":26:26\124t 折磨火输出循环", tooltip = "折磨火输出循环", enabled = true, key = "FireDps" },
};


local function GetSetting(name)
    for k, v in ipairs(items) do
        if v.type == "entry"
         and v.key ~= nil
         and v.key == name then
            return v.value, v.enabled
        end
    end
end;

local function OnLoad()
    ni.GUI.AddFrame("335火法-糊涂虫", items);
end

local function OnUnLoad()  
	ni.GUI.DestroyFrame("335火法-糊涂虫");
end
local spells ={
ArcaneResistance = {id = 20592, name = GetSpellInfo(20592), icon = select(3, GetSpellInfo(20592))},
ArmorSkills = {id = 76276, name = GetSpellInfo(76276), icon = select(3, GetSpellInfo(76276))},
AutoAttack = {id = 6603, name = GetSpellInfo(6603), icon = select(3, GetSpellInfo(6603))},
ColdWeatherFlying = {id = 54197, name = GetSpellInfo(54197), icon = select(3, GetSpellInfo(54197))},
EngineeringSpecialization = {id = 20593, name = GetSpellInfo(20593), icon = select(3, GetSpellInfo(20593))},
EscapeArtist = {id = 20589, name = GetSpellInfo(20589), icon = select(3, GetSpellInfo(20589))},
ExpansiveMind = {id = 20591, name = GetSpellInfo(20591), icon = select(3, GetSpellInfo(20591))},
FlightMastersLicense = {id = 90267, name = GetSpellInfo(90267), icon = select(3, GetSpellInfo(90267))},
Languages = {id = 79740, name = GetSpellInfo(79740), icon = select(3, GetSpellInfo(79740))},
MasterRiding = {id = 90265, name = GetSpellInfo(90265), icon = select(3, GetSpellInfo(90265))},
Mastery = {id = 86473, name = GetSpellInfo(86473), icon = select(3, GetSpellInfo(86473))},
Shoot = {id = 5019, name = GetSpellInfo(5019), icon = select(3, GetSpellInfo(5019))},
ShortbladeSpecialization = {id = 92680, name = GetSpellInfo(92680), icon = select(3, GetSpellInfo(92680))},
WeaponSkills = {id = 76298, name = GetSpellInfo(76298), icon = select(3, GetSpellInfo(76298))},
Wizardry = {id = 89744, name = GetSpellInfo(89744), icon = select(3, GetSpellInfo(89744))},
--Arcane icon = select(2, GetSpellTabInfo(2))
ArcaneBlast = {id = 30451, name = GetSpellInfo(30451), icon = select(3, GetSpellInfo(30451))},
ArcaneBrilliance = {id = 1459, name = GetSpellInfo(1459), icon = select(3, GetSpellInfo(1459))}, --奥术智慧
ArcaneExplosion = {id = 1449, name = GetSpellInfo(1449), icon = select(3, GetSpellInfo(1449))},
ArcaneMissiles = {id = 5143, name = GetSpellInfo(5143), icon = select(3, GetSpellInfo(5143))},
Blink = {id = 1953, name = GetSpellInfo(1953), icon = select(3, GetSpellInfo(1953))}, --闪现
ConjureManaGem = {id = 759, name = GetSpellInfo(759), icon = select(3, GetSpellInfo(759))}, --制造法力石头
ConjureRefreshment = {id = 42955, name = GetSpellInfo(42955), icon = select(3, GetSpellInfo(42955))},
Counterspell = {id = 2139, name = GetSpellInfo(2139), icon = select(3, GetSpellInfo(2139))},
Evocation = {id = 12051, name = GetSpellInfo(12051), icon = select(3, GetSpellInfo(12051))},
Invisibility = {id = 66, name = GetSpellInfo(66), icon = select(3, GetSpellInfo(66))},
MageArmor = {id = 6117, name = GetSpellInfo(6117), icon = select(3, GetSpellInfo(6117))},
MageWard = {id = 543, name = GetSpellInfo(543), icon = select(3, GetSpellInfo(543))},
ManaShield = {id = 1463, name = GetSpellInfo(1463), icon = select(3, GetSpellInfo(1463))}, --法力护盾
FelHealthstone = {id = 36894, name = GetItemInfo(36894)}, --邪能治疗石
ManaGem = {id = 33312, name = GetItemInfo(33312)}, --法力青玉
MirrorImage = {id = 55342, name = GetSpellInfo(55342), icon = select(3, GetSpellInfo(55342))}, --镜像
Polymorph = {id = 118, name = GetSpellInfo(118), icon = select(3, GetSpellInfo(118))}, --变羊
PortalStormwind = {id = 10059, name = GetSpellInfo(10059), icon = select(3, GetSpellInfo(10059))},
PortalIronforge = {id = 11416, name = GetSpellInfo(11416), icon = select(3, GetSpellInfo(11416))},
PortalDarnassus = {id = 11419, name = GetSpellInfo(11419), icon = select(3, GetSpellInfo(11419))},
PortalTheramore = {id = 49360, name = GetSpellInfo(49360), icon = select(3, GetSpellInfo(49360))},
PortalShattrath = {id = 33691, name = GetSpellInfo(33691), icon = select(3, GetSpellInfo(33691))},
PortalDalaran = {id = 53142, name = GetSpellInfo(53142), icon = select(3, GetSpellInfo(53142))},
PortalExodar = {id = 32266, name = GetSpellInfo(32266), icon = select(3, GetSpellInfo(32266))},
PortalTolBarad = {id = 88345, name = GetSpellInfo(88345), icon = select(3, GetSpellInfo(88345))},
RemoveCurse = {id = 475, name = GetSpellInfo(475), icon = select(3, GetSpellInfo(475))},
RitualofRefreshment = {id = 43987, name = GetSpellInfo(43987), icon = select(3, GetSpellInfo(43987))},
SlowFall = {id = 130, name = GetSpellInfo(130), icon = select(3, GetSpellInfo(130))},
Spellsteal = {id = 30449, name = GetSpellInfo(30449), icon = select(3, GetSpellInfo(30449))},
TeleportStormwind = {id = 3561, name = GetSpellInfo(3561), icon = select(3, GetSpellInfo(3561))},
TeleportIronforge = {id = 3562, name = GetSpellInfo(3562), icon = select(3, GetSpellInfo(3562))},
TeleportDarnassus = {id = 3565, name = GetSpellInfo(3565), icon = select(3, GetSpellInfo(3565))},
TeleportExodar = {id = 32271, name = GetSpellInfo(32271), icon = select(3, GetSpellInfo(32271))},
TeleportTheramore = {id = 49359, name = GetSpellInfo(49359), icon = select(3, GetSpellInfo(49359))},
TeleportShattrath = {id = 33690, name = GetSpellInfo(33690), icon = select(3, GetSpellInfo(33690))},
TeleportDalaran = {id = 53140, name = GetSpellInfo(53140), icon = select(3, GetSpellInfo(53140))},
TeleportTolBarad = {id = 88342, name = GetSpellInfo(88342), icon = select(3, GetSpellInfo(88342))},
TimeWarp = {id = 80353, name = GetSpellInfo(80353), icon = select(3, GetSpellInfo(80353))},
--Fire icon = select(2, GetSpellTabInfo(3))
BlastWave = {id = 11113, name = GetSpellInfo(11113), icon = select(3, GetSpellInfo(11113))},
Combustion = {id = 11129, name = GetSpellInfo(11129), icon = select(3, GetSpellInfo(11129))}, --燃烧
DragonsBreath = {id = 31661, name = GetSpellInfo(31661), icon = select(3, GetSpellInfo(31661))}, --龙息术
FireBlast = {id = 2136, name = GetSpellInfo(2136), icon = select(3, GetSpellInfo(2136))}, --火焰冲击
FireSpecialization = {id = 84668, name = GetSpellInfo(84668), icon = select(3, GetSpellInfo(84668))},
Fireball = {id = 133, name = GetSpellInfo(133), icon = select(3, GetSpellInfo(133))}, --火球术
FlameOrb = {id = 82731, name = GetSpellInfo(82731), icon = select(3, GetSpellInfo(82731))},
Flamestrike = {id = 2120, name = GetSpellInfo(2120), icon = select(3, GetSpellInfo(2120))}, --烈焰风暴
FrostfireBolt = {id = 44614, name = GetSpellInfo(44614), icon = select(3, GetSpellInfo(44614))},
LivingBomb = {id = 55360, name = GetSpellInfo(55360), icon = select(3, GetSpellInfo(55360))}, -- 活动炸弹
HotStreak = {id = 48108, name = GetSpellInfo(48108), icon = select(3, GetSpellInfo(48108))}, -- 法术连击
MoltenArmor = {id = 30482, name = GetSpellInfo(30482), icon = select(3, GetSpellInfo(30482))}, --熔岩护甲
Pyroblast = {id = 11366, name = GetSpellInfo(11366), icon = select(3, GetSpellInfo(11366))}, --炎爆术
Scorch = {id = 2948, name = GetSpellInfo(2948), icon = select(3, GetSpellInfo(2948))}, --灼烧
--Frost icon = select(2, GetSpellTabInfo(4))
Blizzard = {id = 10, name = GetSpellInfo(10), icon = select(3, GetSpellInfo(10))}, --暴风雪
ConeofCold = {id = 120, name = GetSpellInfo(120), icon = select(3, GetSpellInfo(120))},
FrostArmor = {id = 7302, name = GetSpellInfo(7302), icon = select(3, GetSpellInfo(7302))},
FrostNova = {id = 122, name = GetSpellInfo(122), icon = select(3, GetSpellInfo(122))},
Frostbolt = {id = 116, name = GetSpellInfo(116), icon = select(3, GetSpellInfo(116))},
IceBlock = {id = 45438, name = GetSpellInfo(45438), icon = select(3, GetSpellInfo(45438))}, --冰箱
IceLance = {id = 30455, name = GetSpellInfo(30455), icon = select(3, GetSpellInfo(30455))},
RingofFrost = {id = 82676, name = GetSpellInfo(82676), icon = select(3, GetSpellInfo(82676))},
}
local enemies = {}

local function ActiveEnemies(range)
	table.wipe(enemies)
	enemies = ni.player.enemiesinrange(40)
	for k, v in ipairs(enemies) do
		if ni.player.threat(v.guid) == -1 then
			table.remove(enemies, k)
		end
	end
	return #enemies
end

local queue = {
    -- "Molten Armor",
    -- "IceBlock",
    -- "Arcane Brilliance",
    -- "Conjure Mana Gem",
    -- "Poly Focus",
	-- "Mana Gem",
    -- "Pause",
    -- "Pyroblast",
    -- "Combustion",
    -- "Living Bomb",
    -- "Fire Blastproc",
    -- -- "Living Bomb AOE",
    -- "BlastWave",
    -- "Flame Orb",
    -- "Flame Strike",
    -- "SorchMoving",
    -- "Dragon Breath",
    -- "Combustion",
    -- "Scorch",
    -- "Fireball",
    -- "Pyroblast",
    -- "LivingBomb",
    "Debug",
    "Pause",         -- 停止动作
    "Prepare",       -- 停止动作
    "Assist",        -- 闪现冰箱
    "KeepHealth",    -- 保命
    "KeepMana",      -- 回蓝
    "RemoveCurse",   -- 解诅咒
    "Spellsteal",    -- 偷魔法
    "AutoBurst",     -- 自动爆发
    "PolyFocus",     -- 焦点变羊
    "Pyroblast",     -- 炎爆术
    "BlizzardAoe",   -- 自动暴风雪
    "FlamestrikeAoe",   -- 自动烈焰风暴
    "LivingBombAoe", -- 群体炸弹
    "Scorch",        -- 灼烧
    "FireDps",       -- 折磨火输出
}

local lyfb = 42926;

local abilities = 
{
    ["Debug"] = function()
		local _, enebled = GetSetting("Debug")
        if enebled then
            ni.vars.debug = true
        else
            ni.vars.debug = false
        end
	end,

    ["Pause"] = function()
		if ni.tnr.pause() then
			return true
        else
            FfsshifapandunaF = FfsshifapandunaF or CreateFrame("frame","FfsshifapandunaF")      
            FfsshifapandunaF:RegisterEvent("UNIT_SPELLCAST_SENT")     
            FfsshifapandunaF:SetScript("OnEvent", function(_,_,a,b,_,c)     
            if a=="player" and b=="烈焰风暴"  then
			   aktm = GetTime() 
			   if GetTime()  -  aktm > 5 then lyfb = 42926  end
			   if lyfb == 42925 then  lyfb = 42926
			   else lyfb = 42925
			   end 
            FfsshifapandunaF:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")  end  end) 
		end
	end,

    ["Prepare"] = function()

        local _, enabled = GetSetting("EquipId")
        if enabled and not UnitAffectingCombat("player") and not ni.unit.buffs("player", "熔岩护甲||冰甲术||法师护甲") then
            local t9 = {47748, 47749, 47750, 47751, 47752, 47753, 47754, 47755, 47756, 47757, 47758, 47759, 47760, 47761, 47762};

            if ni.player.hassetequiped(t9, 2) then  --有2件套
                
            end

            -- 记录替换哪两个，替换回来？
            if not ni.player.hasitemequipped(51378) and ni.player.hasitem(51378) then 
							  
                ni.player.useitem(36892)
            end

            if not ni.player.hasitemequipped(51378) and ni.player.hasitem(51378) then
                ni.player.useitem(36892)
            end
        end

        -- 火盾
        if not ni.unit.buffs("player", "熔岩护甲||冰甲术||法师护甲") and ni.spell.available(spells.MoltenArmor.name) then
            ni.spell.cast(spells.MoltenArmor.name)
            return true
        end

        -- 奥术智慧
        if not ni.unit.buffs("player", "奥术智慧||奥术光辉||达拉然的光辉||达拉然智慧") and ni.spell.available(spells.ArcaneBrilliance.name) then
            ni.spell.cast(spells.ArcaneBrilliance.name)
            return true
        end

        -- 战斗状态不做石头
        if not UnitAffectingCombat("player") and not ni.player.ismoving() and not ni.player.hasitem(spells.ManaGem.name) then
            ni.spell.cast(spells.ConjureManaGem.name)
            return true
        end
	end,

    ["Assist"] = function()
        -- 闪现
		if ni.tnr.isleftshift() and ni.spell.available(spells.Blink.name) then
            ni.spell.cast(spells.Blink.name)
            return true
        end

        local value, enebled = GetSetting("UseHand")
        -- 工程手套
		if enebled then
            ni.tnr.useinventoryitem(10, value)
        end

        -- 工程鞋
		if ni.tnr.isrightctrl() then
            ni.tnr.useinventoryitem(8)
        end
	end,

    ["KeepHealth"] = function() -- 保命
        local stoneValue, stoneEnabled = GetSetting("FelHealthstone") 
        local shieldValue, shieldEnabled = GetSetting("ManaShield")
        local iceBlockValue, iceBlockEnabled = GetSetting("IceBlock")
        local tar = ni.objects["player"];

        -- 法力护盾
		if shieldEnabled and tar:exists() and tar:combat() and tar:hp() < shieldValue and ni.spell.available(spells.ManaShield.name) then
            ni.spell.cast(spells.ManaShield.name)
            return true
        end

        -- 吃糖
        if stoneEnabled and tar:exists() and tar:combat() and tar:hp() < stoneValue and ni.player.itemready(spells.FelHealthstone.name) then
            ni.player.useitem(spells.FelHealthstone.name) 
            return true
        end

        -- 使用冰箱
        if (ni.tnr.isrightshift() or (iceBlockEnabled and tar:exists() and tar:combat() and tar:hp() < iceBlockValue)) and ni.spell.available(spells.IceBlock.name) then
            ni.spell.cast(spells.IceBlock.name)
            return true
        end
	end,

    ["KeepMana"] = function() -- 回蓝
		local manaGemValue, manaGemEnabled = GetSetting("ManaGem")
        local evocationValue, evocationEnabled = GetSetting("Evocation")
        local tar = ni.objects["player"];

        if manaGemEnabled and tar:exists() and tar:combat() and tar:power() < manaGemValue and ni.player.itemready(spells.ManaGem.name) then
            ni.player.useitem(spells.ManaGem.name)
            return true
        end
        if evocationEnabled and tar:exists() and tar:combat() and tar:power() < evocationValue and ni.spell.available(spells.Evocation.name) then
            ni.spell.cast(spells.Evocation.name)
            return true
        end
	end,

    ["PolyFocus"] = function() -- 焦点变羊
        if ni.tnr.attack("focus") and ni.unit.debuffremaining("focus", spells.Polymorph.name) < 2 and ni.tnr.valid("focus", spells.Polymorph.name) then
            ni.spell.cast(spells.Polymorph.name, "focus")
            return true
        end
    end,

    ["RemoveCurse"] = function() -- 解诅咒
        local _, enabled = GetSetting("RemoveCurse")
        if enabled and ni.tnr.attack() then
            ni.tnr.helpmember(spells.RemoveCurse.name, "Curse")
        end
    end,
    
    ["Spellsteal"] = function() -- 偷魔法
        local _, enabled = GetSetting("Spellsteal")
        if enabled and ni.tnr.attack() then
            ni.tnr.removedebuff(spells.Spellsteal.name, "Magic")
        end
    end,

    
    ["AutoBurst"] = function() --爆发
        local _, enabled = GetSetting("AutoBurst")
        if (enabled and ni.unit.buffs("player", "嗜血||英勇||能量灌注")) or ni.tnr.isleftctrl() then
            
            -- 饰品
            ni.tnr.useinventoryitem(13) 
            ni.tnr.useinventoryitem(14)
            -- 燃烧
            if ni.spell.available(spells.Combustion.name) then
                ni.spell.cast(spells.Combustion.name)
            end

            -- 镜像
            if ni.spell.available(spells.MirrorImage.name) then
                ni.spell.cast(spells.MirrorImage.name)
                return true
            end
            
            -- 巨魔狂暴
            if ni.tnr.race() == "巨魔" then
                if ni.spell.available("狂暴") then
                    ni.spell.cast("狂暴")
                    return true
                end
            end

            -- 兽人血性狂怒
            if ni.tnr.race() == "兽人" then
                if ni.spell.available("血性狂怒") then
                    ni.spell.cast("血性狂怒")
                    return true
                end
            end
        end
	end,
    
    ["Pyroblast"] = function() --炎爆术
        local _, enabled = GetSetting("Pyroblast")
        if enabled and ni.tnr.attack() and ni.unit.buff("player", spells.HotStreak.name) and ni.tnr.valid("target", spells.Pyroblast.name) then
            ni.spell.cast(spells.Pyroblast.name)
            return true
        end
	end,

    ["BlizzardAoe"] = function() --暴风雪
        local aoeCount, enabled = GetSetting("BlizzardCount")
        
        if not ni.player.ismoving() and ni.tnr.isleftalt() or (enabled and ni.tnr.enemycount("target", 8) > aoeCount and ni.spell.available("target", spells.Flamestrike.name)) then
            ni.spell.castat(spells.Blizzard.name, "target")
            return true
        end
	end,

    ["FlamestrikeAoe"] = function() --烈焰风暴
        local aoeCount, enabled = GetSetting("FlamestrikeCount")
        if not ni.player.ismoving() and ni.tnr.isrightalt() or (enabled and ni.tnr.enemycount("target", 8) > aoeCount and ni.spell.available("target", spells.Flamestrike.name)) then
            local enemies = ni.unit.enemiesinrange("player", 30) 
            for i = 1, #enemies do
				local target = enemies[i].guid
                ni.spell.castat(lyfb,target)	
                return true
            end
        end
	end,

    ["LivingBombAoe"] = function() -- 群体炸弹
        local distance, enabled = GetSetting("LivingBomb")
        if enabled  then
            ni.tnr.aoecast(spells.LivingBomb.name , distance)
        end
	end,
	
    ["BlastWave"] = function() -- 冲击波
        if ni.vars.combat.aoe 
        and ni.spell.cd(spells.BlastWave.id)== 0
        and ActiveEnemies() > 2 then
            ni.spell.castat(spells.BlastWave.name,"target")
        end
    end,

    ["Flame Strike"] = function() -- 烈焰风暴
        if ni.vars.combat.aoe 
        and ActiveEnemies() > 2 then
            ni.spell.delaycast(spells.Flamestrike.name,"target", 8)
            ni.player.clickat("target")
        end
    end,

    ["Flame Orb"] = function() -- CTM/MOP技能
        if ni.spell.cd(spells.FlameOrb.id)== 0
        and ni.player.isfacing("player","target")
        then
            ni.spell.cast(spells.FlameOrb.name)
            return true
        end
    end,

    
	["Combustion"] = function() -- 燃烧
        local _, enabled = GetSetting("Combustion")
        if enabled
            and ni.vars.combat.cd
            and UnitAffectingCombat("player")
            and ni.spell.cd(spells.Combustion.id) == 0
            and not ni.unit.ischanneling("player")
            and ni.unit.debuff("target", 92315)
            and ni.unit.debuff("target", 44457)
            and ni.unit.debuff("target", 12654) then
                ni.spell.stopcasting()
                ni.spell.cast(26297) --Racial Troll
                ni.player.runtext("/use 13") -- Activable trinket 
                ni.player.useitem(58091) --Spell potion 
                ni.spell.cast(spells.Combustion.name, "target")
                return true;
        end
    end,

    ["Dragon Breath"] = function() --龙息术，暂时没用到
        if ni.spell.available(spells.DragonsBreath.id) 
        and ni.unit.inmelee("player", "target") then
            ni.spell.cast(spells.DragonsBreath.name)
        end
    end,

    ["Scorch"]= function() --灼烧
        local _, enabled = GetSetting("Scorch")
        if enabled and ni.tnr.attack() and ni.unit.isboss("target") and ni.tnr.valid("target", spells.Scorch.name) and not ni.unit.debuffs("target", "强化灼烧||暗影掌握") then -- Improved Scorch --
            ni.spell.delaycast(spells.Scorch.name, "target", 1.5)
            return true;
        end
    end,

    ["FireDps"] = function () --折磨火输出循环
        local _, enabled = GetSetting("FireDps")
        
        if enabled and ni.tnr.attack() then
            if ni.unit.buff("player", spells.HotStreak.name) and ni.tnr.valid("target", spells.Pyroblast.name) then
                ni.spell.cast(spells.Pyroblast.name)
            end
            if ni.unit.debuffremaining("target", spells.LivingBomb.name, "player") <= 0 and ni.tnr.valid("target", spells.LivingBomb.name, false) then -- 活动炸弹不用面对目标
                ni.spell.cast(spells.LivingBomb.name)
            end
            if not ni.player.ismoving() and ni.tnr.valid("target", spells.Fireball.name) then
                ni.spell.cast(spells.Fireball.name, "target")
            end
            if ni.tnr.valid("target", spells.FireBlast.name) then
                ni.spell.cast(spells.FireBlast.name)
            end
        end
    end,
} 

ni.bootstrap.profile("335火法", queue, abilities, OnLoad, OnUnload);


-- Impact despues fireblast 
-- Check para Combustion 
--  92315 and ignite 1265
-- Check for a good ignite
